Fix hemisphere check in GDB reader.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 30 Jun 2005 18:46:25 +0000 (18:46 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 30 Jun 2005 18:46:25 +0000 (18:46 +0000)
gpsbabel/gdb.c

index 7c83bd6b467952f25fc85adf6c939b087d68f3ac..efd0054140c82ae91e8f5b058b5117f979227f1a 100644 (file)
@@ -448,6 +448,8 @@ gdb_read_wpt(const size_t fileofs, int *wptclass)
        /* might need to change this to handle version dependent icon handling */
        res->icon_descr = gdb_find_desc_from_icon_number(xicon, MAPSOURCE);
        
+       gdb_is_valid(fabs(res->latitude) <= 90.0 && fabs(res->longitude) <= 180.0, " - wpt read: invalid lat or lon");
+
        return res;
 }
 
@@ -532,8 +534,7 @@ gdb_read_route(void)
            xlat = GPS_Math_Semi_To_Deg(semilat);
            xlon = GPS_Math_Semi_To_Deg(semilon);
            
-           gdb_is_valid(fabs(xlat) < 180.0 && fabs(xlon) < 180.0, " - rte: read loop: invalid lat or lon");
-           gdb_is_valid(fabs(xlat) > 1 && fabs(xlon) > 1, " - rte: read loop: invalid lat or lon");
+           gdb_is_valid(fabs(xlat) <= 90.0 && fabs(xlon) <= 180.0, " - rte: read loop: invalid lat or lon");
            
            xalt = unknown_alt;
            fread(buff, 1, 1, fin);                             /* altitude flag */
@@ -541,7 +542,6 @@ gdb_read_route(void)
            {
                gdb_fread_le(fin, &xalt, sizeof(xalt), 64, "xalt");
            }
-           gdb_is_valid(xlat > 1 && xlon > 1, " - rte: read loop");
 
            wpt = gdb_create_rte_wpt(xwptname, xlat, xlon, xalt);
            route_add_wpt(route, wpt);
@@ -554,7 +554,7 @@ gdb_read_route(void)
                if (buff[0] == 1) gdb_fread_le(fin, &xalt, sizeof(xalt), 64, "xalt");
                xlat = GPS_Math_Semi_To_Deg(semilat);
                xlon = GPS_Math_Semi_To_Deg(semilon);
-               gdb_is_valid(xlat > 1 && xlon > 1, " - rte/ils: read loop: invalid lat or lon");
+               gdb_is_valid(fabs(xlat) <= 90.0 && fabs(xlon) <= 180.0, " - rte/ils: read loop: invalid lat or lon");
            }
            
            fread(buff, 1, 1, fin);                     /* NULL */
@@ -691,11 +691,6 @@ gdb_read_track(const size_t max_file_pos)
            if (buff[0] == 1)
                gdb_fread_le(fin, &xtemp, sizeof(xtemp), 64, "xtemp");
            
-#if GDB_DEBUG
-           printf("trk: %g - %g (%08x - %08x)\n", 
-               GPS_Math_Semi_To_Deg(xlat), GPS_Math_Semi_To_Deg(xlon), xlat, xlon);
-#endif
-
            wpt = waypt_new();
            
            wpt->latitude = GPS_Math_Semi_To_Deg(xlat);
@@ -705,6 +700,8 @@ gdb_read_track(const size_t max_file_pos)
            wpt->altitude = xalt;
            wpt->depth = xdepth;
            
+           gdb_is_valid(fabs(wpt->latitude) <= 90.0 && fabs(wpt->longitude) <= 180.0, " - trk read loop: invalid lat or lon");
+           
            route_add_wpt(track, wpt);
        }